const express = require('express');
const router = express.Router();
const bookController = require('../controllers/bookController');
const {isAdmin} = require("../middlewares/adminMiddleware");
const {authenticateToken} = require("../middlewares/authMiddleware");
const upload = require('../config/multer');

router.get('/info', bookController.getBooks);
router.get('/search', bookController.searchBook);
router.post('/add', authenticateToken, isAdmin, bookController.addBook);
router.delete('/delete/:id', authenticateToken, isAdmin, bookController.deleteBook);
router.put('/items/:id', authenticateToken, isAdmin, bookController.updateBook);
router.get('/total', authenticateToken, isAdmin, bookController.bookNum);
router.post('/upload', upload.single('image'), bookController.upLoad);
router.delete('/deleteimage', bookController.deleteImage);

module.exports = router;